home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / hard / hack / i2clib40.lha / i2clib40 / Install < prev    next >
Text File  |  1998-09-13  |  6KB  |  175 lines

  1.  
  2. (set @default-dest (expandpath "LIBS:"))
  3. (set #safedelay 10)
  4.  
  5. ;--------------------------- Englische Texte ----------------------------
  6.  
  7. (set #pathprompt "Select a destination directory for the i2c.library binary:")
  8. (set #pathhelp (cat "\nYou might want to change the given default "
  9.         "directory (which is essentially LIBS:), if you have a strict policy "
  10.         "of keeping system libraries and non-system libraries in separate "
  11.         "places.") )
  12. (set #hwchoiceprompt "Pick your type of I²C interface:")
  13. (set #hwchoice0 "SERIAL PORT, as proposed by \"c't\" magazine")
  14. (set #hwchoice1 "serial port, Wiegand VTX 2000 hardware")
  15. (set #hwchoice2 "serial port, HSL VideoTXT hardware")
  16. (set #hwchoice3 "serial port, KDK Satcom PC-Videotext")
  17. (set #hwchoice4 "PARALLEL PORT, as proposed by Jan Leuverink")
  18. (set #hwchoice5 "parallel port, Printtechnik teletext")
  19. (set #hwchoice6 "parallel port, Microtext hardware")
  20. (set #hwchoice7 "autoconfig board, M&T TeleTxt")
  21. (set #hwchoice8 "FLOPPY PORT")
  22. (set #hwchoicehelp (cat "\nDepending on the kind of interface hardware you "
  23.         "own, you can have one of several customized i2c.library versions "
  24.         "installed. Those interfaces which are described in the accompanying "
  25.         "schematics are CAPITALIZED.\n\n") )
  26. (set #delayprompt "Enter a timing parameter for i2c.library:" )
  27. (set #delayhelp (cat "\nSetting too small a delay parameter will keep "
  28.         "i2c.library from working properly.\n\n"
  29.         "While a value of " #safedelay " should be safe for all systems (and "
  30.         "has indeed just been confirmed to work for you, too), you might "
  31.         "want to try smaller values, to optimize throughput: "
  32.         "5 has often been reported to work for AA Amigas (i.e. A1200/A4000), "
  33.         "1 for all the older ECS/OCS models.\n\n"
  34.         "Hint: You don't have to run this script every time you want to "
  35.         "try a new delay value. To test a value of 5, for example, you "
  36.         "would execute the following from a shell prompt: \"I2Cscan -d5\", "
  37.         "and if the result is okay: \"SetEnv I2CDELAY 5\" and \"Copy "
  38.         "ENV:I2CDELAY ENVARC:\"." ) )
  39. (set #okmsg (cat "Communication with your I²C peripheral(s) was successfully "
  40.         "established. Congratulations.") )
  41. (set #advice (cat "\n\nHint: If you think that you chose the wrong type of "
  42.         "library, you might want to reset your Amiga before running this "
  43.         "script again. That would make sure that the current i2c.library is "
  44.         "removed from memory, and might save you a lot of confusion.") )
  45. (set #diagmsg5 (cat "I2CScan could not detect any listeners on your I²C bus. "
  46.         "This might of course be just because there aren't any?" #advice ) )
  47. (set #diagmsg10 (cat "I2CScan couldn't test your interface, because "
  48.         "i2c.library either failed to detect it, or failed to access it "
  49.         "(possibly due to resource conflicts)." #advice ) )
  50. (set #diagmsg15 (cat "I²C protocol errors occured while running I2CScan. "
  51.         "This might be because your hardware is not appropriate for the "
  52.         "type of i2c.library that you installed." #advice ) )
  53. (set #diagmsg20 "I2CScan failed to open i2c.library. This is weird." )
  54. (set #timingmsg (cat "Your I2CDELAY parameter was poorly chosen and has been "
  55.         "reset to the default value of " #safedelay ".") )
  56.  
  57. ;---------------------------- Default values ----------------------------
  58.  
  59. (set #hwtype 0)         ; c't-Hardware
  60. (set #busdelay (getenv "I2CDELAY"))
  61. (if (= "" #busdelay)
  62.     (set #busdelay #safedelay)
  63. )
  64.  
  65. ;--------------------------- Interview, part 1 --------------------------
  66.  
  67. (if (= @user-level 2)       ; this question for experts only
  68.     (set @default-dest
  69.         (askdir
  70.             (prompt #pathprompt)
  71.             (help #pathhelp)
  72.             (default @default-dest)
  73.         )
  74.     )
  75. )
  76.  
  77. (set #hwtype
  78.     (askchoice
  79.         (prompt #hwchoiceprompt)
  80.         (help #hwchoicehelp)
  81.         (choices #hwchoice0 #hwchoice1 #hwchoice2 #hwchoice3 #hwchoice4
  82.                  #hwchoice5 #hwchoice6 #hwchoice7 #hwchoice8 )
  83.         (default #hwtype)
  84.     )
  85. )
  86.  
  87. ;-------------------------- Installation, part 1 ------------------------
  88.  
  89. ; Copy the library binary.
  90. (set #sourcefile
  91.     (select #hwtype
  92.       "libs/i2c.library.ser"
  93.       "libs/i2c.library.ser2"
  94.       "libs/i2c.library.ser3"
  95.       "libs/i2c.library.ser4"
  96.       "libs/i2c.library.par"
  97.       "libs/i2c.library.par2"
  98.       "libs/i2c.library.par3"
  99.       "libs/i2c.library.card"
  100.       "libs/i2c.library.disk"
  101.     )
  102. )
  103. (copyfiles
  104.     (source #sourcefile)
  105.     (dest @default-dest)
  106.     (newname "i2c.library")
  107. )
  108.  
  109. ; Try to purge a currently loaded image.
  110. (run "Avail FLUSH >NIL:")
  111.  
  112. ; Befor asking for an optimized delay value, does this library work at all?
  113. (set #result
  114.     (run (cat "bin/I2CScan -d" #safedelay " >NIL:") )
  115. )
  116. (set #farewell #okmsg)
  117. (if (= #result 20)
  118.     (set #farewell #diagmsg20)
  119. )
  120. (if (= #result 15)
  121.     (set #farewell #diagmsg15)
  122. )
  123. (if (= #result 10)
  124.     (set #farewell #diagmsg10)
  125. )
  126. (if (= #result 5)
  127.     (set #farewell #diagmsg5)
  128. )
  129.  
  130. ;--------------------------- Interview, part 2 --------------------------
  131.  
  132. (if (= #result 0)           ; Alright, it works with the safe value. Optimize?
  133. (
  134.  
  135. (if (= @user-level 2)       ; this question for experts only
  136.     (set #busdelay
  137.         (asknumber
  138.             (prompt #delayprompt)
  139.             (help #delayhelp)
  140.             (range 0 100)
  141.             (default #busdelay)
  142.         )
  143.     )
  144. )
  145.  
  146. ; Test the current setting of #busdelay
  147. (set #result
  148.     (run (cat "bin/I2CScan -d" #busdelay " >NIL:") )
  149. )
  150. (if (<> #result 0)          ; poorly chosen delay parameter
  151.     (
  152.     (set #farewell #timingmsg)
  153.     (set #busdelay #safedelay)
  154.     )
  155. )
  156.  
  157. )
  158. )   ; #result 0
  159.  
  160. ;-------------------------- Installation, part 2 ------------------------
  161.  
  162. ; create the I2CDELAY environment variable
  163. (textfile
  164.     (dest "ENV:I2CDELAY")
  165.     (append #busdelay)
  166. )
  167. (textfile
  168.     (dest "ENVARC:I2CDELAY")
  169.     (append #busdelay)
  170. )
  171.  
  172. ;------------------------------- Farewell -------------------------------
  173.  
  174. (exit #farewell)
  175.